package com.yanjue.fallback;

import com.yanjue.client.homePageBookVOClient;
import com.yanjue.common.util.Result;
import com.yanjue.common.util.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class homePageBookVOFallback implements FallbackFactory<homePageBookVOClient> {
    private static final Logger LOGGER = LoggerFactory.getLogger(homePageBookVOFallback.class);
    @Override
    public homePageBookVOClient create(Throwable cause) {
        //发生异常，降级
        return new homePageBookVOClient() {
            @Override
            public Result getBooklistPagingBooks(Integer booklistId, Integer page, Integer limit) {
                LOGGER.error("booklistId [{}]失败：{}", booklistId, cause.getMessage());
                return ResultUtil.success(0);
            }
        };
    }
}
